/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkgModuloPrincipal.pkgConfiguracionRegional;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.ParseException;
import java.util.Locale;

/**
 *
 * @author Armando
 */
public class Context {

    private Locale LOCALE;
    private DecimalFormat DECIMAL_FORMAT = new DecimalFormat();
    private DecimalFormatSymbols DECIMAL_FORMAT_SYMBOLS = new DecimalFormatSymbols();

    public Context() {
    }

    public Context(Locale locale) {
        LOCALE = locale;
    }

    /**
     * @return the DECIMAL_FORMAT
     */
    public DecimalFormat getDECIMAL_FORMAT() {
        return DECIMAL_FORMAT;
    }

    private static class SingletonContext {

        private static Context instancia = new Context();

        private static Context getSingletonContext() {
            return instancia;
        }
    }

    public static Context getSingletonContext() {
        return SingletonContext.getSingletonContext();
    }

    public Locale getLocale() {
        return LOCALE;
    }

    public void setLocale(Locale locale) {
        LOCALE = locale;
    }

    public void setConfiguration(ContextEntity cEntity) {
        LOCALE = new Locale(cEntity.getLanguage(), cEntity.getCountry());
        Locale.setDefault(LOCALE);

        DECIMAL_FORMAT = (DecimalFormat) DecimalFormat.getInstance(LOCALE);
        DECIMAL_FORMAT_SYMBOLS = DecimalFormatSymbols.getInstance(LOCALE);
        
        DECIMAL_FORMAT_SYMBOLS.setDecimalSeparator(cEntity.getSepDecimales());
        DECIMAL_FORMAT_SYMBOLS.setGroupingSeparator(cEntity.getSepMiles());

        getDECIMAL_FORMAT().setDecimalFormatSymbols(DECIMAL_FORMAT_SYMBOLS);
    }

    public void setLocale_EsArg() {
        LOCALE = new Locale(Constants.ENUM_LOCALE.LANGUAGE_ESPANIOL.toString(), Constants.ENUM_LOCALE.COUNTRY_ARGENTINA.toString());
        Locale.setDefault(LOCALE);

        DECIMAL_FORMAT = (DecimalFormat) DecimalFormat.getInstance(LOCALE);
        DECIMAL_FORMAT_SYMBOLS = DecimalFormatSymbols.getInstance(LOCALE);
    }

    public void setLocale_EnUS() {
        LOCALE = new Locale(Constants.ENUM_LOCALE.LANGUAGE_INGLES.toString(), Constants.ENUM_LOCALE.COUNTRY_US.toString());
        Locale.setDefault(LOCALE);

        DECIMAL_FORMAT = (DecimalFormat) DecimalFormat.getInstance(LOCALE);
        DECIMAL_FORMAT_SYMBOLS = DecimalFormatSymbols.getInstance(LOCALE);
    }

    public DecimalFormatSymbols getDECIMAL_FORMAT_SYMBOLS() {
        return DECIMAL_FORMAT_SYMBOLS;
    }

    
}
